<?php

namespace App\Http\Controllers\Api\Mall;

use App\Http\Controllers\Controller;
use App\Pointcard;
use App\PointCardQueue;
use Illuminate\Http\Request;

class PointcardController extends Controller
{
    /**
     * @function 积分卡列表
     *
     * @param Request $request
     * @return $this
     */
    public function pointcardList(Request $request)
    {
        $pointcards = Pointcard::select('id', 'images', 'price')->get();

        return response()->json(['code' => '1000', 'data' => $pointcards])->withCallback($request->input('callback'));
    }

    /**
     * @function 积分卡状态
     *
     * @param Request $request
     * @return $this
     */
    public function pointcardStatus(Request $request)
    {
        $status=$request->input('status');

        $user = auth()->user();

        $queue = PointCardQueue::where('user_id', $user->id)
            ->join('point_card', 'point_card.id', '=', 'point_card_queue.card_id')
            ->select('images','price','point_card_queue.user_id')
            ->where('point_card_queue.status',$status)
            ->get();

        return response()->json(['code' => '1000', 'data' => $queue])->withCallback($request->input('callback'));

    }

}
